Introduction
The SuiteQL Query Tool is a powerful NetSuite Suitelet application designed for developers, administrators, and analysts who need to query NetSuite data using SuiteQL. It provides a modern, intuitive interface inspired by professional SQL IDEs like SQL Server Management Studio and Azure Data Studio.
Developed by Tim Dietrich, this open-source tool transforms the way you interact with NetSuite's SuiteQL capabilities, offering features like syntax highlighting, auto-complete, query history, and multiple export formats.
Installation
Follow these steps to install the SuiteQL Query Tool in your NetSuite account:
1
Upload the Script File
Navigate to Documents > Files > File Cabinet in NetSuite. Create a folder for your scripts (e.g., SuiteScripts/SuiteQL) and upload the suiteql-query-tool.v2026.1.suitelet.js file.
2
Create a Script Record
Go to Customization > Scripting > Scripts > New. Select the uploaded file and click Create Script Record. Fill in the details:
- Name: SuiteQL Query Tool
- ID: _suiteql_query_tool (or your preferred ID)
- Script File: Select the uploaded file
3
Deploy the Script
After saving the script record, click Deploy Script. Configure the deployment:
- Title: SuiteQL Query Tool
- ID: _suiteql_query_tool (or your preferred ID)
- Status: Released
- Audience: Select the roles that should have access
- Log Level: Error (recommended for production)
4
Access the Tool
After deployment, you can access the tool via the external URL provided in the deployment record, or by navigating to Customization > Scripting > Script Deployments and clicking the deployment link.
Tip: Bookmark the Suitelet URL for quick access, or add it to your NetSuite dashboard as a custom portlet link.
Features Overview
AI Query Generator
Describe what you need in plain English and get working SuiteQL queries instantly. Supports 7 AI providers.
Natural Language Query Bar
Quick input bar above the editor - type plain English and generate queries directly.
AI Query Explain
Click "Explain" to have AI break down complex queries into plain English.
AI Query Validation
AI reviews your query before execution, warning about potential issues.
AI Tables Reference
Ask AI about any table, find the right tables, and generate queries from selected columns.
Query Optimization
For slow queries, AI suggests indexes, better joins, and restructuring.
SQL Syntax Highlighting
CodeMirror-powered editor with full SQL syntax highlighting and line numbers.
Auto-Complete
Table and column name suggestions with Ctrl+Space for faster query writing.
Query History
Automatically saves your query history locally for easy access to previous queries.
Dark Mode
Toggle between light and dark themes for comfortable viewing in any environment.
Multiple Export Formats
Export results to Excel (.xlsx), CSV, JSON, or copy directly to clipboard.
Cloud Export
Export directly to Google Sheets or Airtable with batching and progress tracking.
Column Statistics
View SUM, AVG, MIN, and MAX for numeric columns in your results.
Query Parameters
Use {{variable}} syntax for dynamic queries with prompted input.
Query Sharing
Generate shareable URLs that include your query for easy collaboration.
Column Pinning
Freeze the first 1-3 columns while scrolling horizontally through results.
Drag & Drop Import
Import SQL files by dragging and dropping them onto the editor.
Column Reordering
Drag column headers to reorder columns in the results table.
Results Maximized
Hide the editor to view results in full-screen mode.
Data Visualization / Charts
Create bar, line, pie, doughnut, and polar area charts from query results with AI-assisted generation.
Clickable Record Links
ID columns automatically link to NetSuite records. Click to open customers, transactions, items, and more.
Plugin Architecture
Extend the tool with custom plugins. Add hooks, UI elements, and server-side processing.
Generate Suitelet
Create standalone SuiteScript Suitelets from Document Generator templates with one click.
ERD Generation
Interactive Entity Relationship Diagrams with export to SVG, PNG, and DOT formats.
Extended Schema Export
Export schemas to BigQuery, Snowflake, Redshift, dbt YAML, Avro, Markdown, and more.
Getting Started
Your First Query
When you first open the SuiteQL Query Tool, you'll see a sample query in the editor. You can modify this or write your own query. Here's a simple example to get started:
SELECT
id,
companyname,
email,
datecreated
FROM
customer
WHERE
isinactive = 'F'
ORDER BY
datecreated DESC
Click the Run Query button or press Ctrl + Enter to execute the query.
Understanding the Interface
- Toolbar: Contains buttons for running queries, accessing the query library, importing/exporting, and more.
- Editor Panel: Where you write your SuiteQL queries with syntax highlighting.
- Results Panel: Displays query results in table, DataTable, or JSON format.
- Sidebar: Shows your query history (toggle with the sidebar button).
- Status Bar: Shows the current status and execution times.
Using the Query Editor
Writing Queries
The editor supports standard SuiteQL syntax with SQL highlighting. SuiteQL is NetSuite's SQL-like query language that allows you to query NetSuite records.
Auto-Complete
Press Ctrl + Space to trigger auto-complete suggestions. The tool provides suggestions for:
- Common NetSuite table names (Customer, Transaction, Item, etc.)
- Column names for known tables
- SQL keywords
Tip: Enable auto-complete from the Options panel to get suggestions as you type.
Query Parameters
Use double curly braces to create dynamic parameters in your queries:
SELECT * FROM customer
WHERE datecreated >= '{{Start Date}}'
AND datecreated <= '{{End Date}}'
When you run the query, you'll be prompted to enter values for each parameter. The tool remembers your last-used values.
Importing SQL Files
You can import SQL files in two ways:
- Drag & Drop: Simply drag a .sql file onto the editor area.
- Import Button: Click the Import button in the toolbar and select a file.
Undo/Redo History
Click the history icon in the toolbar to view and restore previous editor states. This is useful if you accidentally delete or modify your query.
Working with Results
View Modes
The results panel offers three view modes:
- Table: Simple, fast table view with all features (pinning, reordering, statistics).
- DataTable: Enhanced table with built-in sorting, filtering, and pagination.
- JSON: Raw JSON output for developers.
Row Details
Click any row in the results to open a detailed view showing all fields for that record. Use the arrow keys to navigate between rows while the detail view is open.
Clickable Record Links
ID columns in your results automatically become clickable links to the corresponding NetSuite records:
- Supported record types include Customers, Vendors, Employees, Items, Transactions, Subsidiaries, Departments, Classes, Locations, Accounts, and more
- Clicking a linked ID opens the record in a new browser tab
- Links work in Table view, DataTable view, and the Row Details modal
- Visual feedback: linked IDs show a blue background with white text on hover
- Toggle "Link IDs to records" in the Options panel (enabled by default)
Column Features
- Reordering: Drag column headers to rearrange columns.
- Pinning: Use the "Pin columns" option to freeze the first 1-3 columns while scrolling.
- Statistics: Enable "Show statistics" to see SUM, AVG, MIN, MAX for numeric columns.
Exporting Results
Click the Export button to export your results:
- Excel (.xlsx): Native Excel format with proper formatting.
- CSV: Comma-separated values for universal compatibility.
- JSON: JavaScript Object Notation for programmatic use.
- Copy: Copy results to clipboard in CSV format.
- Google Sheets: Export directly to a Google Spreadsheet (requires Service Account setup).
- Airtable: Export to an Airtable base (requires API token).
Results Maximized Mode
Press Shift + R or click the expand button to hide the editor and maximize the results panel. Press Esc or click the button again to restore.
Keyboard Shortcuts
Press ? at any time to view the keyboard shortcuts modal.
| Action |
Shortcut |
| Run Query |
Ctrl + Enter |
| Format Query |
Ctrl + Shift + F |
| Save Query |
Ctrl + S |
| Undo |
Ctrl + Z |
| Redo |
Ctrl + Shift + Z |
| Auto-Complete |
Ctrl + Space |
| Maximize Results |
Shift + R |
| Exit Focus/Maximized Mode |
Esc |
| Previous Row (in details) |
← |
| Next Row (in details) |
→ |
| Show Shortcuts |
? |
Note: On Mac, use Cmd instead of Ctrl.
Advanced Features
Query Library
Access the built-in Query Library from the toolbar to browse pre-built queries for common NetSuite tasks. These queries serve as useful examples and starting points for your own queries.
Tables Reference
Click Tables Reference in the toolbar to open a new window with a searchable list of all NetSuite tables available for querying.
Focus Mode
Click the Focus Mode button (expand arrows icon) in the header to hide the NetSuite navigation and maximize your workspace. Combined with Results Maximized mode, you can dedicate your entire screen to query results.
Query Sharing
Click Share in the toolbar to generate a URL that includes your current query. Anyone with access to the Suitelet can use this URL to open the tool with your query pre-loaded.
Auto-Save Draft
Your current query is automatically saved to local storage as you type. If you accidentally close the browser or navigate away, your query will be restored when you return.
Execution Time Tracking
The tool tracks execution times for your queries, displayed in the results header. This helps you optimize query performance.
AI Query Generator
The AI Query Generator allows you to describe your data needs in plain English and receive working SuiteQL queries. It supports seven AI providers including Anthropic, OpenAI, Cohere, xAI/Grok, Google Gemini, Mistral AI, and OpenAI-compatible endpoints.
Getting Started with AI
1
Configure Your API Key
Click the AI button in the toolbar, then click the gear icon to open settings. Select your provider, enter your API key, and choose a model.
2
Describe Your Query
Type a natural language description of the data you need. For example: "Show me all active customers with their sales rep" or "Find invoices from last month over $1000".
3
Insert and Run
Click Insert Query to add the generated SQL to the editor. Enable Auto-execute query to run it immediately.
Features
- Conversational Refinement: The chat history persists, so you can ask follow-up questions like "Now exclude inactive employees" or "Add the department name".
- Multiple Providers: Choose from seven AI providers:
- Anthropic (Claude Sonnet 4, Claude 3.5 Sonnet, Claude 3.5 Haiku)
- OpenAI (GPT-4o, GPT-4o Mini, GPT-4 Turbo)
- Cohere (Command A, Command R+, Command R)
- xAI/Grok (Grok 3, Grok 3 Fast, Grok 2)
- Google Gemini (Gemini 2.0 Flash, Gemini 1.5 Pro, Gemini 1.5 Flash)
- Mistral AI (Mistral Large, Mistral Small, Codestral)
- OpenAI-Compatible (custom endpoints like OpenRouter, Azure OpenAI, local models)
- Secure Key Storage: Choose whether to remember your API key in local storage or enter it each session.
- One-Click Insert: Generated queries include Insert and Copy buttons for easy use.
- API Debug Modal: When AI errors occur, click "Show Details" to see the full request/response for troubleshooting.
Tips for Better Results
- Be specific about the fields you need: "Show customer name, email, and phone" vs just "Show customers"
- Mention filtering criteria: "Only active records" or "From the last 30 days"
- Specify sorting if needed: "Ordered by date descending"
- If the query isn't quite right, ask for adjustments in the same conversation
AI-Enhanced Features
Beyond the conversational AI Query Generator, the tool offers several AI-powered features integrated directly into the editor toolbar.
Natural Language Query Bar
Click the Ask button in the toolbar to toggle the natural language query bar. This provides a quick way to generate queries without opening the full AI modal:
- Type a description like "Show me overdue invoices over $1000"
- Press Enter or click Generate
- The query is inserted directly into the editor
Your visibility preference is saved, so the bar will remember whether you prefer it shown or hidden.
Explain Query
Click the Explain button (lightbulb icon) to have AI analyze your current query and explain it in plain English. This is useful for:
- Understanding inherited or unfamiliar queries
- Learning what each part of a complex query does
- Documenting queries for team members
The explanation covers: what data is retrieved, tables used, joins and their purpose, filter conditions, and sorting/grouping.
Validate Query
Click the Validate button (shield icon) before running your query to have AI check for potential issues:
- Missing WHERE clause: Query might return too many rows
- Cartesian joins: Missing join conditions creating cross products
- SELECT *: Should specify columns explicitly
- Missing table aliases: Can cause ambiguity
- Performance concerns: Large table scans, missing filters
- Syntax issues: Common SuiteQL mistakes
The validation panel shows issues found and suggestions for improvement, with options to "Run Anyway" or close.
Query Optimization Suggestions
When a query takes longer than 5 seconds to execute, a banner appears offering AI optimization suggestions:
- Click Optimize to open the AI modal with a pre-filled optimization request
- AI analyzes your query and suggests improvements
- Recommendations include: index suggestions, better join strategies, query restructuring, and filtering improvements
Tip: All AI features require API key configuration. Click the AI button and then the gear icon to set up your credentials for any of the seven supported providers.
Tables Reference
Click Tables in the toolbar to open the Tables Reference in a new window. This powerful tool helps you explore NetSuite's database schema with AI assistance.
Basic Features
- Search: Filter tables by name using the search box
- Table Details: Click any table to view its columns, data types, and available joins
- Sample Query: Each table shows a sample SELECT query you can copy
- Focus Mode: Click the fullscreen button to hide NetSuite chrome
- Dark Mode: Toggle between light and dark themes
AI-Powered Table Search
Toggle to AI Find mode to search for tables using natural language:
- Describe what data you need: "I need customer payment history"
- AI suggests relevant tables with explanations
- Table names in AI responses are clickable links
Ask AI About This Table
When viewing any table's details, you'll see an "Ask AI About This Table" section with preset questions:
- What is this table used for? - Explains the table's purpose in NetSuite
- Show me a sample query - Generates a practical query example
- How to join with Customer? - Shows how to connect this table to Customer records
- Most important columns? - Highlights key columns and their purposes
- Ask custom question... - Opens a chat for your own questions
Generate Query from Selection
Build queries by selecting columns from the table detail view:
1
Select Columns
Use the checkboxes next to each column to select the fields you want. Use "Select All" or "Clear" for quick selection.
2
Generate Query
Click the Generate Query button. AI will create a practical query with your selected columns, including appropriate WHERE conditions and JOIN suggestions.
Tip: The Tables Reference shares AI settings with the main query tool, so you only need to configure your API key once.
Schema Explorer
The Schema Explorer builds a complete picture of your NetSuite database schema, respecting your role-based permissions. Access it from the Tables button dropdown or from within the Tables Reference.
Building Your Schema
Click Schema Explorer to open the tool. The first time you use it, click Build Schema to scan all available tables. This process:
- Queries all tables visible to your role
- Captures column names, data types, and relationships
- Stores the schema in IndexedDB for persistence
- Only needs to be rebuilt when your role changes or new tables are added
Export Formats
Once your schema is built, you can export it in multiple formats:
- JSON: Complete schema data for programmatic use
- MySQL DDL: CREATE TABLE statements for MySQL
- PostgreSQL DDL: CREATE TABLE statements for PostgreSQL
- SQLite DDL: CREATE TABLE statements for SQLite
- SQL Server DDL: CREATE TABLE statements for SQL Server
- BigQuery DDL: CREATE TABLE statements for Google BigQuery
- Snowflake DDL: CREATE TABLE statements for Snowflake
- Amazon Redshift DDL: CREATE TABLE statements for Redshift
- dbt YAML: dbt sources configuration file (netsuite_sources.yml)
- Apache Avro: Avro schema JSON for Kafka/streaming pipelines
- Markdown: Comprehensive schema documentation with table of contents
- DBML: Database Markup Language for dbdiagram.io
- Graphviz DOT: For OmniGraffle, Graphviz, and other DOT-compatible tools
The export grid shows common formats by default. Click "Show All Formats" to reveal advanced export options.
ERD Generation
Generate interactive Entity Relationship Diagrams directly in the browser:
- Scope Options: View all related tables, select specific tables, or explore connected subsets
- Display Options: Show/hide columns, primary keys, foreign keys, and cardinality labels
- Layout Direction: Choose top-to-bottom, left-to-right, or other orientations
- Diagram Style: Classic or hand-drawn appearance
- Interactive Zoom: Mouse wheel zoom with configurable default level
- Export: Save diagrams as SVG, PNG, or DOT format
- Mermaid Integration: Copy Mermaid code or open in Mermaid Live editor
Schema-Based Autocomplete
Enable "Use full schema" in the Options panel (under Autocomplete) to leverage your Schema Explorer data for enhanced autocomplete:
- Completions for ALL tables visible to your role (500+)
- Column suggestions with data types (e.g., "trandate (DATE)")
- Falls back to the static table list when schema data isn't available
Tip: Build your schema once, then enable "Use full schema" for comprehensive autocomplete across your entire NetSuite database.
Document Generator
The Document Generator creates formatted PDF and HTML documents from your query results using FreeMarker/XML templates.
Template Editor
The template editor includes a full-featured CodeMirror toolbar:
- Undo/Redo: Navigate through editing history
- Find and Replace: Search and replace text in your template
- Font Size: Increase or decrease editor font size
- Word Wrap: Toggle line wrapping for long lines
- Fold/Unfold: Collapse or expand code sections
- Go to Line: Jump to a specific line number
- Active Line Highlighting: Current line is visually highlighted
- Bracket Matching: Matching brackets are highlighted
AI Template Generation
Click AI Generate to create templates using natural language:
- Describe your desired document layout in plain English
- AI generates complete FreeMarker/XML templates
- Context-aware: knows your available data sources and column names
- NetSuite-specific: trained on BFO PDF renderer requirements
- Uses correct FreeMarker patterns (alias.records, null-safe operators)
Template Refinement
When your editor has existing code, the AI modal switches to Refine mode:
- Describe the changes you want to make
- AI returns a complete modified template
- Choose to replace the current template or append the generated code
Generate Suitelet
Click Generate Suitelet to create a standalone SuiteScript 2.1 Suitelet from your current template and queries:
- Script Configuration: Optionally set a Script ID for the JSDoc @NScriptId tag
- Commenting Level: Choose None, Minimal, or Verbose code comments
- Output Mode: Select whether the generated Suitelet displays inline or triggers a download
- Multi-Query Support: All your data sources are included with named aliases
- Parameter Detection: Automatically detects {{param}} syntax and generates URL parameter handling
- Code Preview: Review the generated code with syntax highlighting before saving
- Export Options: Copy to clipboard or download as a .js file
The generated Suitelet includes a CONFIG object for easy customization and is ready to deploy in NetSuite.
Charts / Data Visualization
Visualize your query results with interactive charts powered by Chart.js.
Creating Charts
After running a query, click the Chart button in the results toolbar to open the chart configuration panel:
- Chart Types: Bar, Line, Pie, Doughnut, and Polar Area
- Manual Configuration: Select label (X-axis) and value (Y-axis) columns from your results
- AI-Assisted Generation: Describe the chart you want in natural language
- Theme-Aware Colors: Charts automatically adapt to light/dark mode
- Multi-Dataset Support: Create comparison charts with multiple data series
Using AI for Charts
Click AI Generate in the chart panel to describe what you want to visualize:
- "Show sales by month as a bar chart"
- "Create a pie chart of customers by state"
- "Compare revenue vs expenses over time"
AI automatically selects the appropriate chart type and column mappings based on your data.
Exporting Charts
Click Export as PNG to save your chart as an image file for use in reports and presentations.
Tip: The chart feature automatically detects numeric columns in your results, making it easy to identify which columns can be used as values.
Plugin Architecture
Extend the SuiteQL Query Tool with custom plugins. Plugins can add UI elements, hook into query execution, and process results.
Enabling Plugins
To enable plugin support, set the PLUGIN_FOLDER_ID in the script's CONFIG object to the internal ID of a File Cabinet folder containing your plugin files:
const CONFIG = Object.freeze({
PLUGIN_FOLDER_ID: 12345,
});
Plugin File Format
Plugin files must be named with the extension .sqt-plugin.js or .sqt-plugin.json. The tool automatically discovers and loads all plugin files in the specified folder.
Server-Side Hooks
Plugins can implement server-side hooks to process queries:
- onBeforeQuery: Modify queries before execution (add filters, transform SQL)
- onAfterQuery: Process results after execution (add computed columns, transform data)
- onError: Handle query errors (logging, notifications)
- Custom Handlers: Add custom server endpoints accessible via fetch
Client-Side Hooks
Plugins can respond to client events:
- onInit: Called when the app initialization completes
- onBeforeQuery / onAfterQuery: Hook into the query lifecycle
- onResultsDisplay: Customize how results are rendered
- onBeforeExport / onAfterExport: Intercept export operations
- onEditorChange: Respond to editor content changes
UI Injection Points
Plugins can inject custom UI elements at 17 predefined locations:
- Toolbar: toolbar-start, toolbar-end, more-dropdown, ai-dropdown
- Header: header-right
- Editor: before-editor, editor-toolbar, nl-bar
- Results: results-header, results-footer (via hooks)
- Sidebar: sidebar-section
- Modals: export-menu, local-library-actions, modals
- Other: options-panel, status-bar
Plugin API
Plugins have access to the public API through the SQT namespace:
SQT.plugins - Plugin management functions
SQT.getResults() - Get current query results
SQT.getQuery() / SQT.setQuery() - Read/write editor content
SQT.getEditor() - Access the CodeMirror instance
SQT.showModal() / SQT.hideModal() - Modal control
Feature Disabling
Plugins can disable built-in features using the disables[] array. This allows plugins to replace or hide default functionality. Over 20 features can be disabled including AI, export, history, and more.
Tip: A sample plugin (query-logger.sqt-plugin.js) is included with the tool demonstrating server/client hooks, UI injection, and settings management. See the PLUGIN-GUIDE.md file for complete documentation.
Configuration Options
Click the Options button in the toolbar to access configuration settings:
Pagination
- Row Begin / Row End: Specify the range of rows to return.
- Return All: Fetch all matching records (use with caution on large datasets).
Display Options
- Hide Row Numbers: Remove the row number column from results.
- Show Statistics: Display SUM, AVG, MIN, MAX for numeric columns.
- Pin Columns: Freeze the first 1-3 columns while scrolling.
- Link IDs to Records: When enabled, ID columns become clickable links that open the corresponding NetSuite records. Enabled by default.
- Render HTML in Results: When enabled, HTML content in query results is rendered instead of escaped. Useful for queries that build hyperlinks (e.g., anchor tags linking to records).
NULL Display
- Dimmed: Show NULL values in gray italic text.
- Empty: Display nothing for NULL values.
- Explicit: Show the text "NULL".
Script Configuration
Advanced users can modify the CONFIG object at the top of the script file:
const CONFIG = Object.freeze({
VERSION: '2026.1',
DATATABLES_ENABLED: true,
REMOTE_LIBRARY_ENABLED: true,
ROWS_RETURNED_DEFAULT: 100,
QUERY_FOLDER_ID: null,
PLUGIN_FOLDER_ID: null,
WORKBOOKS_ENABLED: false,
MAX_HISTORY_ENTRIES: 50,
SLOW_QUERY_THRESHOLD_MS: 3000,
AI_ENABLED: true,
AI_RESULTS_CHAT_ENABLED: false
});
AI Configuration Options
- AI_ENABLED: Master switch to enable/disable all AI features. When set to
false, hides all AI-related UI elements including the AI dropdown, natural language query bar, optimization suggestions, and AI features in Tables Reference.
- AI_RESULTS_CHAT_ENABLED: When enabled, allows users to ask AI questions about query results. Disabled by default for data privacy considerations.
- SLOW_QUERY_THRESHOLD_MS: Milliseconds before showing the optimization suggestions banner (default: 3000ms).
Plugin Configuration
- PLUGIN_FOLDER_ID: Set to the internal ID of a File Cabinet folder to enable plugin loading. Plugins in this folder with
.sqt-plugin.js or .sqt-plugin.json extensions will be automatically loaded.
Troubleshooting
Common Issues
"Invalid search filter" or similar errors
This usually indicates a syntax error in your SuiteQL query. Check for:
- Misspelled table or column names
- Missing quotes around string values
- Incorrect date formats (use 'YYYY-MM-DD')
Query returns no results
- Verify your WHERE clause conditions
- Check if the records exist and are not inactive
- Ensure you have permission to view the records
Performance issues with large datasets
- Use pagination (Row Begin/End) instead of returning all records
- Add WHERE clauses to filter results
- Select only the columns you need instead of using SELECT *
Auto-complete not working
- Ensure auto-complete is enabled in the Options panel
- Try pressing Ctrl + Space manually
Important: SuiteQL has some limitations compared to standard SQL. Not all SQL functions are supported, and some NetSuite-specific syntax may be required. Refer to NetSuite's SuiteQL documentation for details.
Getting Help
For additional help:
- Press ? to view keyboard shortcuts
- Click the Help button (question mark icon) in the toolbar
- Consult NetSuite's SuiteQL documentation
- Visit timdietrich.me for more resources